import React, { Component } from 'react'
import "./index.css"
import Item from '../Item'
import PropTypes from "prop-types" // yarn add prop-types
export default class List extends Component {
    // 对传入的数据进行限制
    static propTypes = {//propTypes  前面的P小写
        todos: PropTypes.array.isRequired,
        updateTodo: PropTypes.func.isRequired
    }
    render() {
        const { todos, updateTodo, deleteTodo } = this.props

        return (
            <ul className="todo-main">
                {
                    todos.map(todo => { return <Item key={todo.id} {...todo} updateTodo={updateTodo} deleteTodo={deleteTodo} /> })
                }
            </ul>
        )
    }
}
